package logic

import (
	"context"
	"videos/model/mysql"

	"videos/videorpc/internal/svc"
	"videos/videorpc/videorpc"

	"github.com/zeromicro/go-zero/core/logx"
)

type VideoDetailLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewVideoDetailLogic(ctx context.Context, svcCtx *svc.ServiceContext) *VideoDetailLogic {
	return &VideoDetailLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *VideoDetailLogic) VideoDetail(in *videorpc.VideoDetailRequest) (*videorpc.VideoDetailResponse, error) {
	// todo: add your logic here and delete this line

	var video mysql.VideoUserTopic

	err := video.VideoDetail(mysql.DB, in.VideoId)
	if err != nil {
		return nil, err
	}

	return &videorpc.VideoDetailResponse{
		VideoId:  int64(video.VideoId),
		Title:    video.Title,
		Style:    video.Style,
		NickName: video.NickName,
	}, nil
}
